#include "stdafx.h"
#include "SimpleRefection.h"
#include "GlobalClassManager.h"

bool GlobalClassManager::RegisterClass(CClass& rClass,int32 iSubID,int32 iGroupID)
{
	int32 iID=MakeClassID(iGroupID,iSubID);
	std::map<int32,const CClass*>::iterator it=m_mClasses.find(iID);
	if(it!=m_mClasses.end()) return false;
	m_mClasses[iID]=&rClass;
	rClass.SetClassID(iID);
	return true;
}

const CClass* GlobalClassManager::LookupClass( int32 iGroup,int32 iSubID )
{
	int32 iID=MakeClassID(iGroup,iSubID);
	std::map<int32,const CClass*>::iterator it=m_mClasses.find(iID);
	if(it==m_mClasses.end()) return NULL;
	return it->second;
}
const CClass* GlobalClassManager::LookupClass( int32 iID)
{
	std::map<int32,const CClass*>::iterator it=m_mClasses.find(iID);
	if(it==m_mClasses.end()) return NULL;
	return it->second;
}



void GlobalClassManager::EnumerateClasses( std::vector<const CClass*>& vClasses )
{
	vClasses.clear();
	std::map<int32,const CClass*>::iterator it= m_mClasses.begin();

	for(;it!=m_mClasses.end();it++)
	{
		const CClass* pClass=it->second;
		vClasses.push_back(pClass);
	}
}